<template>
  <div id="box">
    <admin-header />
    <div class="main">
      <el-container>
        <el-aside :width="isCollapse ? '4.5%' : '13%'">
          <el-menu class="hidden-btn">
            <div>
              <i class="icon font_family" 
                :class="[isCollapse ? 'icon-a-zhedie2' : 'icon-a-icon-zhedie-fuben-fuben']"
                @click="hidetabs">
              </i>
            </div>
          </el-menu>
          <el-menu 
              unique-opened
              :collapse="isCollapse"
              :collapse-transition="false"
              >
              <!-- :collapse="isCollapse" 表示水平折叠时隐藏菜单 -->
              <!-- unique-opened 表示只保持一个菜单打开 -->

            <!-- 已完成 -->
            <el-menu-item class="home">
              <i class="icon font_family icon-yiwancheng"></i>
              <span 
                  :class="[isCollapse ? 'hidden_tab':'tab']"
                  @click="$router.push('/finish-data')">
                已完成
              </span> 
            </el-menu-item>

            <!-- 未完成 -->
            <el-menu-item class="home">
              <i class="icon font_family icon-weiwancheng"></i>
              <span 
                  :class="[isCollapse ? 'hidden_tab':'tab']"
                  @click="$router.push('/un-finish-data')">
                未完成
              </span> 
            </el-menu-item>

            <!-- 查找 -->
            <el-menu-item class="home">
              <i class="icon font_family icon-chazhao"></i>
              <span 
                  :class="[isCollapse ? 'hidden_tab':'tab']"
                  @click="$router.push('/filter')">
                查找
              </span> 
            </el-menu-item>
          </el-menu>
        </el-aside>
        <router-view 
          :class="[isCollapse ? 'main-content_max' : 'main-content_min']">
        </router-view>
      </el-container>
    </div>
  </div>
</template>

<script>
  import AdminHeader from 'components/AdminHeader.vue'
  export default {
    name: 'Home',
    components: {
      AdminHeader
    },
    data() {
      return {
        isCollapse: false
      }
    },
    methods: {
      hidetabs() {
        this.isCollapse = !this.isCollapse
        // 点击 【隐藏图标】修改 vuex 中的 isCollapse
        let collapse = !this.isCollapse
        this.$store.commit('fun', collapse);
      }
    },
  }  
</script>

<style lang="less" scoped>
  .main {
    width: 100%;
    .el-container {
      width: 100%;
      height: max-content;
      border: 1px solid #eee;
      .el-aside {
        background-color: cornflowerblue;
        height: 440px;
        position: fixed;
        // margin-top: 50px;
        background-color: rgb(238, 241, 246);
        .hidden-btn {
          padding: 2px 0;
          text-align: center;
          background-color: #2c3a50;
          background-color: rgba(#2c3a50, 0.5);
          border-bottom: 1px solid #ccc;
          .icon {
            color: #fff;
            cursor: pointer;
          }
        }
        .el-menu {
          overflow: hidden;
          .home {
            color: #fff;
            height: 50px;
            background-color: #2c3a50;
            text-align: center;
            border-bottom: 1px solid #999;
          }
          .tab {
            padding: 0 0 0 10px;
          }
          .hidden_tab {
            display: none;
          }
          .el-sub-menu {
            color: #fff;
            background-color: #2c3a50;
            text-align: center;
            border-bottom: 1px solid #999;
            .tab, i {
              color: #fff;
            }
          }
          .el-sub-menu:hover {
            color: #000;
            .tab, i {
              color: #000;
            }
          }
        }
      }
      // isCollapse = false 侧边栏展开
      .main-content_min {
        padding-left: 175px;
      }
      // isCollapse = true 侧边栏折叠
      .main-content_max {
        width: 100%;
        padding: 0 10px 0 70px;
      }
    }
  }
</style>

<style>
  .el-sub-menu .el-menu-item {
    min-width: 0;
  }
  .el-sub-menu__title {
    height: 50px;
    color: #fff;
  }
  .el-sub-menu__title:hover {
    color: #999;
  }
  .el-aside {
    max-height: 80vh;
    overflow: auto;
  } 
  .el-menu--collapse {
    width: 57px;
  }
</style>
